package com.jinzecloud.fiction.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.jinzecloud.fiction.utils.PageUtils;
import com.jinzecloud.fiction.utils.R;
import com.mysql.cj.log.Log;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jinzecloud.fiction.bean.TbAuthor;
import com.jinzecloud.fiction.service.TbAuthorService;


/**
 * 作者表
 *
 * @author ??
 * @email 1971240051@qq.com
 * @date 2023-10-19 19:38:04
 */
@Slf4j
@RestController
@RequestMapping("fiction/tbauthor")
//@Api(tags = "作者 API 接口")
public class TbAuthorController {
    @Autowired
    private TbAuthorService tbAuthorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @ApiOperation(value = "",notes = "保存文件",httpMethod = "GET")
    //@RequiresPermissions("fiction:tbauthor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbAuthorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{auId}")
    //@RequiresPermissions("fiction:tbauthor:info")
    public R info(@PathVariable("auId") Integer auId){
		TbAuthor tbAuthor = tbAuthorService.getById(auId);

        return R.ok().put("tbAuthor", tbAuthor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("fiction:tbauthor:save")
    public R save(@RequestBody TbAuthor tbAuthor){
		tbAuthorService.saveTbAuthor(tbAuthor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("fiction:tbauthor:update")
    public R update(@RequestBody TbAuthor tbAuthor){
		tbAuthorService.updateTbAuthorById(tbAuthor);

        return R.ok();
    }

    @RequestMapping("/updateStatus")
    //@RequiresPermissions("fiction:tbauthor:update")
    public R updateStatus(@RequestBody TbAuthor tbAuthor){
        tbAuthorService.updateTbAuthorStatus(tbAuthor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("fiction:tbauthor:delete")
    public R delete(@RequestBody Integer[] auIds){
		tbAuthorService.removeByIds(Arrays.asList(auIds));

        return R.ok();
    }

}
